-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support string and array multiline, and integer representation encoding #183
Conversation
One more suggestion is: To get the following result:
What do you think? |
Yep, I thought about that and it's definitely doable, but I figured that would be a feature to add later. We can make an issue about this. There's two ways I could see this being represented in the I think the first would be preferred |
ktoml-core/src/commonMain/kotlin/com/akuleshov7/ktoml/writers/TomlEmitter.kt
Outdated
Show resolved
Hide resolved
If groupSize = 3 what does it mean? Will it be like this: |
Yep, that's the idea |
ktoml-core/src/commonMain/kotlin/com/akuleshov7/ktoml/writers/TomlEmitter.kt
Fixed
Show fixed
Hide fixed
221b93d
to
276a27e
Compare
ktoml-core/src/commonMain/kotlin/com/akuleshov7/ktoml/writers/TomlEmitter.kt
Outdated
Show resolved
Hide resolved
) | ||
} | ||
|
||
//private fun emitInt(value: Long) |
Check failure
Code scanning / ktlint
[COMMENT_WHITE_SPACE] there should be a white space between code and comment also between code start token and comment text: There should be 1 space(s) before comment token in //private fun emitInt(value: Long)
3548304
to
d36a0cf
Compare
# Conflicts: # ktoml-core/src/commonMain/kotlin/com/akuleshov7/ktoml/tree/nodes/pairs/values/TomlBasicString.kt
Surprisingly not much conflicts |
yeah, I am also confused - came here to look at conflicts :) |
It will also be good to add a description with all such annotations like |
) : TomlValue() { | ||
public constructor(content: String, lineNo: Int) : this(content.toLong()) | ||
public constructor(content: String, lineNo: Int) : this(content.parse()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually I do not get it - if you remember I was always avoiding custom logic for parsing and even made logic for parsing based on exceptions:
try {
s.toLong
} catch() {
try {
s.toInt
}
}
...
etc.
So I tried as much as possible to avoid custom parsing and use parsing from stdlib. Why do we need to have it here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I did it this way to support parsing the other integer types, instead of just decimal. toLong
only parses decimal numbers, it can't handle the prefixes and non-decimal bases that TOML supports, like 0b
, 0x
, etc. We can do it a different way if you have something in mind
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that this parsing of prefixes is included into toLong
… I got the intention now
when { | ||
multiline -> | ||
when { | ||
multilineControlCharacterRegex in this -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Regular expressions affect performance and in some cases can lead to exceptions in case of very long strings...
May it will be better to use something like string.any(setOfillegalCharacters::contains)
instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, admittedly regexes aren't needed here. I assume you want a separate issue for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I will make a separate one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Basically lgtm, but I am a little bit worried about:
- custom parsing of Long
- a little bit unreadable regular expressions that can also affect the performance
Fixes #161